package entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * The persistent class for the friends database table.
 * 
 */
@Entity
@Table(name="lotterygames")

@NamedQueries({

@NamedQuery(name="getAvailableLotteries", 
		query="SELECT x FROM LotteryGame x WHERE x.drawnNumber=0 AND x.active = 1"),
		
@NamedQuery(name="getActiveLottery", 
		query="SELECT x.id FROM LotteryGame x WHERE x.drawnNumber>0 AND x.active = 1")
				
})

public class LotteryGame implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="Id", unique=true, nullable=false)
	private int id;
	
	@Temporal( TemporalType.TIMESTAMP)
	@Column(name="DrawDay", nullable=false)
	private Date drawDay;
	
	@Column(name="DrawnNumber", nullable=false)
	private int drawnNumber = 0;
	
	@Column(name="Active", nullable=false)
	private int active;
	
	//bi-directional many-to-one association to LindenBets
	@OneToMany(mappedBy="lotteryGame")
	private List<LindenBet> lindenBets;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getDrawDay() {
		return drawDay;
	}

	public void setDrawDay(Date drawDay) {
		this.drawDay = drawDay;
	}

	public int getDrawnNumber() {
		return drawnNumber;
	}

	public void setDrawnNumber(int drawnNumber) {
		this.drawnNumber = drawnNumber;
	}

	public List<LindenBet> getLindenBets() {
		return lindenBets;
	}

	public void setLindenBets(List<LindenBet> lindenBets) {
		this.lindenBets = lindenBets;
	}


}
